home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu745.dms / pu745.adf / GLOBE099.LHA / Ami-Globe / main_old.c < prev    next >
C/C++ Source or Header  |  1993-11-04  |  30KB  |  1,364 lines

  1. /********************************/
  2. /* AmiGlobe            */
  3. /* T.Landspurg            */
  4. /********************************/
  5.  
  6. /* INCLUDES ********************************************************** */
  7.  
  8. /* MUI */
  9. #include <libraries/mui.h>
  10.  
  11. #include <exec/types.h>
  12. #include <exec/io.h>
  13. #include <exec/memory.h>
  14. #include <exec/libraries.h>
  15. #include <libraries/dos.h>
  16. #include <intuition/intuition.h>
  17. #include <graphics/gfxmacros.h>
  18.  
  19. /* Prototypes */
  20. #include <clib/alib_protos.h>
  21. #include <clib/exec_protos.h>
  22. #include <clib/dos_protos.h>
  23. #include <clib/icon_protos.h>
  24. #include <clib/graphics_protos.h>
  25. #include <clib/intuition_protos.h>
  26. #include <clib/gadtools_protos.h>
  27. #include <clib/muimaster_protos.h>
  28. #include <clib/asl_protos.h>
  29. /* ANSI C */
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <stdio.h>
  33. #include <ctype.h>
  34.  
  35.  
  36. #define REG(x) register __ ## x
  37. #define ASM    __asm
  38. #define SAVEDS __saveds
  39.  
  40. #include <pragmas/exec_pragmas.h>
  41. #include <pragmas/dos_pragmas.h>
  42. #include <pragmas/icon_pragmas.h>
  43. #include <pragmas/graphics_pragmas.h>
  44. #include <pragmas/intuition_pragmas.h>
  45. #include <pragmas/gadtools_pragmas.h>
  46. #include <pragmas/muimaster_pragmas.h>
  47. #include <pragmas/asl_pragmas.h>
  48.  
  49. /*
  50. extern struct Library *IntuitionBase;
  51. extern struct Library *GfxBase;
  52. extern struct Library *DOSBase;
  53. */
  54. extern struct Library *UtilityBase;
  55. extern struct Library *IconBase;
  56.  
  57. struct Library *MUIMasterBase;
  58.  
  59.  
  60. /*
  61. #include <libraries/reqbase.h>
  62. */
  63.  
  64. #ifdef    LATTICE
  65. #include    <proto/all.h>
  66. #endif
  67.  
  68. #include "amiglobe_types.h"
  69. #include "main_protos.h"
  70.  
  71. #ifndef MAKE_ID
  72. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  73. #endif
  74.  
  75. /*** ids ***/
  76.  
  77. enum ids {
  78.     ID_DUMMY,
  79.     ID_ABOUT,
  80.     ID_REDRAW,
  81.     ID_INFO,
  82.     ID_FILL,
  83.     ID_MOVE_PT,
  84.     ID_ZOOM,
  85.     ID_ZOOM_OUT,
  86.     ID_SHOW_PT,
  87.     ID_EDIT,
  88.     ID_MODE_EDIT,
  89.     ID_MODE_NOT_EDIT
  90.     };
  91.  
  92.  
  93. struct NewMenu Menu[] =
  94. {
  95.     { NM_TITLE, "Project"  , 0 ,0,0,(APTR)0            },
  96.     { NM_ITEM , "About..." ,"?",0,0,(APTR)ID_ABOUT     },
  97.     { NM_ITEM , NM_BARLABEL, 0 ,0,0,(APTR)0            },
  98.     { NM_ITEM , "Quit"     ,"Q",0,0,(APTR)MUIV_Application_ReturnID_Quit },
  99.     { NM_END  , NULL       , 0 ,0,0,(APTR)0            },
  100. };
  101.  
  102.  
  103. static APTR AP_Main;
  104.  
  105. static WI_Cmd,WI_Cmd_Edit;
  106.  
  107.  
  108. static    APTR    BT_Cmd_Panel,BT_Redraw,BT_Info,BT_Fill;
  109. static    APTR    BT_Move,BT_Zoom,BT_Zoom_Out,BT_Show_Pt,BT_Edit;
  110.  
  111. #define HProp                    PropObject, PropFrame, MUIA_Prop_Horiz, TRUE, MUIA_FixHeight, 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  112. #define VProp                    PropObject, PropFrame, MUIA_Prop_Horiz, FALSE, MUIA_FixWidth , 8, MUIA_Prop_Entries, 111, MUIA_Prop_Visible, 10, End
  113.  
  114. int    max_border=0;
  115.  
  116. /* Tableau de pointeurs sur les vecteurs */
  117.     
  118. BORDER    *tab_vect;
  119. COUNTRY    *tab_country;
  120.  
  121. int    max_country=0;        /* Nombre max de pays        */
  122. int    country_sel=-1;        /* Pays courant selectionne */
  123. BOOL    flg_edit=FALSE;
  124.  
  125. /**********************************/
  126. /* Tableau des noms de continents */
  127. /**********************************/
  128.  
  129. char    *cont_name[]={"Europe","New contry"};
  130.  
  131. long minx, miny, maxx, maxy;
  132. int    cx=320;
  133. int    cy=100;
  134.  
  135.  
  136. USHORT quit_flag = FALSE;
  137.  
  138.  
  139. struct IntuitionBase *IntuitionBase=0;
  140. struct GfxBase    *GfxBase=0;
  141. struct ReqBase    *ReqBase;
  142.  
  143. struct Window *OpenWindow();
  144. struct Screen *OpenScreen();
  145.  
  146. struct Screen *sC;
  147. struct ViewPort vP;
  148.  
  149. struct Window *wG,*cmd_wG;    /* we fetch the RastPort pointer from here */
  150. struct RastPort *rpG,*cmd_rpG;
  151.  
  152. struct    TmpRas    tmpras;        /* Pour les areadraw */
  153. struct    AreaInfo myareainfo;
  154. WORD    areabuffer[MAX_AREA_PT*3];
  155.  
  156. int    signal_wG,signal_cmd_wG,signal_all;
  157.  
  158. /****************************************************************************/
  159.  
  160. /* This is for the event handler */
  161. void quit(void)
  162. {
  163.     quit_flag = TRUE;
  164. }
  165. void cmd1(void)
  166. {
  167.     cmd_edit();
  168. }
  169. void cmd_redraw(void)
  170. {
  171.     printf("Cmd redraw!\n");
  172.     redraw_map(-1);
  173. }
  174. void cmd_fill(void)
  175. {
  176.     int    i;
  177.     for(i=0;i<max_country;i++){
  178.         fill_country(i,i+1);
  179.     }
  180. }
  181.  
  182.  
  183. void cmd_select_country(void)
  184. {
  185.     country_sel=sel_country(max_country,print_pays);
  186.     aff_selection();
  187.  
  188. }
  189.  
  190. void cmd_sel_continent(void)
  191. {
  192.     int num_cont;
  193.     printf("Sel continent!\n");
  194.     num_cont=sel_country(MAX_CONTINENT,print_cont);
  195.     redraw_map(num_cont);
  196. }
  197.  
  198. void cmd_info(void)
  199. {
  200.     aff_info(country_sel);
  201. }
  202.  
  203. /****************************************************************************/
  204.  
  205. /* get the PowerWindows 2.0 code */
  206. #include "windowdef.h"
  207.  
  208. /****************************************************************************/
  209.  
  210. void    cmd_edit(void)
  211. {
  212. /*
  213.     if(cmd_wG!=NULL)CloseWindow(cmd_wG);
  214.     edit();
  215.     cmd_wG = OpenWindow(&NewWindowStructure2);
  216. */
  217. }
  218.  
  219. /****************************************************************************/
  220.  
  221. void IPrint(
  222.     struct    RastPort *rpG,
  223.     int    x,
  224.     int    y,
  225.     char    *p_texte
  226.     )
  227. {
  228.     SetAPen(rpG,1);
  229.     SetDrMd(rpG,JAM2);
  230.     Move(rpG,x,y);
  231.     Text(rpG,p_texte,strlen(p_texte));
  232. }
  233.  
  234. /****************************************************************************/
  235.  
  236. void WaitButton(void)
  237. {
  238.     UWORD code;
  239.     ULONG class;
  240.     struct IntuiMessage *message;
  241.     int    flg_quit;
  242.  
  243.     flg_quit=FALSE;
  244.     do{
  245.         WaitPort(wG->UserPort);
  246.         while( (message = (struct IntuiMessage *)
  247.                 GetMsg(wG->UserPort) ) != NULL)
  248.         {
  249.             code = message->Code;  /* MENUNUM */
  250.             class = message->Class;
  251.             ReplyMsg((struct Message *)message);
  252.             if(( class == MOUSEBUTTONS)&&( code == SELECTDOWN)){
  253.                 flg_quit=TRUE;
  254.             }
  255.         }
  256.     }while(flg_quit==FALSE);
  257. }
  258.  
  259. /****************************************************************************/
  260.  
  261. void aff_country(int    num_pays)
  262. {
  263.     int    omx,omy,OMX,OMY;
  264.     char buffer[100];
  265.  
  266.     sprintf(buffer,"Info sur:%s",tab_country[num_pays].name);
  267.  
  268.     omx=minx;
  269.     omy=miny;
  270.     OMX=maxx;
  271.     OMY=maxy;
  272.  
  273.     minx=tab_country[num_pays].c_clip.minx-50;
  274.     miny=tab_country[num_pays].c_clip.miny-50;
  275.     maxx=tab_country[num_pays].c_clip.maxx+50;
  276.     maxy=tab_country[num_pays].c_clip.maxy+50;
  277.  
  278.     SetRast(rpG,0L);
  279.     fill_country(num_pays,2);
  280.     IPrint(rpG,50,20,buffer);
  281.  
  282.     minx=omx;
  283.     miny=omy;
  284.     maxx=OMX;
  285.     maxy=OMY;
  286. }
  287.  
  288. /****************************************************************************/
  289.  
  290. void aff_pnb(void)
  291. {
  292.     int    i;
  293.     int    color;
  294.  
  295.     for(i=0;i<max_country;i++){
  296.         color=(16*tab_country[i].pnb1)/300;
  297.         fill_country(i,color);
  298.     }
  299. }
  300.  
  301. /****************************************************************************/
  302.  
  303. void    aff_info_page1(int    num_pays)
  304. {
  305.     char buffer[100];
  306.     sprintf(buffer,"Info sur:%s",tab_country[num_pays].name);
  307.  
  308.     SetRast(rpG,0L);
  309.     SetAPen(rpG,1L);
  310.     SetBPen(rpG,0L);
  311.  
  312.     IPrint(rpG,50,20,buffer);
  313.     sprintf(buffer,"Taux de croissance:%d",10);
  314.     IPrint(rpG,10,50,buffer);
  315.     sprintf(buffer,"Investissements:%d",10);
  316.     IPrint(rpG,10,60,buffer);
  317.     sprintf(buffer,"Habitants:%d",tab_country[num_pays].habitants);
  318.     IPrint(rpG,10,70,buffer);
  319.     sprintf(buffer,"Continent:%s",cont_name[tab_country[num_pays].continent]);
  320.     IPrint(rpG,10,80,buffer);
  321.     sprintf(buffer,"Pnb89:%d",tab_country[num_pays].pnb1);
  322.     IPrint(rpG,10,90,buffer);
  323.     sprintf(buffer,"Pnb90:%d",tab_country[num_pays].pnb2);
  324.     IPrint(rpG,10,100,buffer);
  325.     sprintf(buffer,"Pnb91:%d",tab_country[num_pays].pnb3);
  326.     IPrint(rpG,10,110,buffer);
  327.  
  328. }
  329. /******************************************************** aff_info() ******/
  330.  
  331. void aff_info(int num_pays)
  332. {
  333.  
  334.     /* Verification qu'un pays est selectionne */
  335.     printf("Aff info,num pays:%d\n",num_pays);
  336.     if(num_pays!=-1){
  337. /*
  338.         ModifyIDCMP(wG,MOUSEBUTTONS);
  339. */
  340.         /*************************/
  341.         /* Affichage de la carte */
  342.         /*************************/
  343.         aff_country(num_pays);
  344.         WaitButton();
  345.  
  346.         aff_info_page1(num_pays);
  347.         WaitButton();
  348.  
  349. /*
  350.         aff_pnb();
  351.         WaitButton();
  352. */
  353. /*
  354.         ModifyIDCMP(wG,    NewWindowStructure1.IDCMPFlags);
  355. */
  356.         redraw_map(-1);
  357.     }
  358. }
  359.  
  360. /******************************************************** print_pays() ****/
  361.  
  362. void print_pays(struct    RastPort *rpG)
  363. {
  364.     int    i,posx,posy;
  365.     posx=0;
  366.     posy=0;
  367.     for(i=0;i<max_country;i++){
  368.         if(posy>8){
  369.             posy=0;
  370.             posx++;
  371.         }
  372.         Move(rpG,10+posx*100,20+posy*10);
  373.         Text(rpG,tab_country[i].name,strlen(tab_country[i].name));
  374.         posy++;
  375.     }
  376. }
  377.  
  378. void print_cont(struct    RastPort *rpG)
  379. {
  380.     int    i;
  381.     for(i=0;i<MAX_CONTINENT;i++){
  382.         Move(rpG,10,20+i*10);
  383.         Text(rpG,cont_name[i],strlen(cont_name[i]));
  384.     }
  385. }
  386.  
  387. /****************************************************************************/
  388. void MyDraw(
  389.     struct    RastPort *rpG,
  390.     int    x,
  391.     int    y
  392.     )
  393. {
  394.     int    x1,y1;
  395.     x1=(((x-minx)*(wG->GZZWidth))/(maxx - minx)),
  396.     y1=(((y-miny)*(wG->GZZHeight))/(maxy-miny));
  397.     Draw(rpG,x1,y1);
  398. }
  399.  
  400. /****************************************************************************/
  401.  
  402. void MyMove(
  403.     struct    RastPort *rpG,
  404.     int    x,
  405.     int    y
  406.     )
  407. {
  408.     int    x1,y1;
  409.     x1=(((x-minx)*(wG->GZZWidth))/(maxx - minx)),
  410.     y1=(((y-miny)*(wG->GZZHeight))/(maxy-miny));
  411.     Move(rpG,x1,y1);
  412. }
  413. /****************************************************************************/
  414.  
  415. int conv_inv_x(
  416.     int    x
  417.     )
  418. {
  419.     x=(x*(maxx-minx))/(wG->GZZWidth)+minx;
  420.     return(x);
  421. }
  422. /****************************************************************************/
  423. int conv_inv_y(
  424.     int    y)
  425. {
  426.     y=(y*(maxy-miny))/(wG->GZZHeight)+miny;
  427.     return(y);
  428. }
  429. /****************************************************************************/
  430.  
  431. int conv_x(x)
  432. int    x;
  433. {
  434.     x=(((x-minx)*(wG->GZZWidth))/(maxx - minx));    
  435.     return(x);
  436. }
  437. /****************************************************************************/
  438.  
  439. int conv_y(
  440.     int    y
  441.     )
  442. {
  443.     y=(((y-miny)*(wG->GZZHeight))/(maxy - miny));
  444.     return(y);
  445. }
  446.  
  447. /****************************************************************************/
  448.  
  449. void    draw_rect(
  450.     struct    RastPort *rpG,
  451.     int    x,
  452.     int    y,
  453.     int    sx,
  454.     int    sy
  455.     )
  456. {
  457.     Move(rpG,x,y);
  458.     Draw(rpG,x+sx,y);
  459.     Draw(rpG,x+sx,y+sy);
  460.     Draw(rpG,x,y+sy);
  461.     Draw(rpG,x,y);
  462. }
  463.  
  464. void    aff_selection(void)
  465. {
  466.     char    buffer[100];
  467.  
  468.     if((country_sel>=max_country)||(country_sel<0)){
  469.         country_sel=-1;
  470.         sprintf(buffer,"Sel:          ");
  471.     }else{
  472.         sprintf(buffer,"Sel:%10s",tab_country[country_sel].name);
  473.     }
  474.     IPrint(rpG,200,20,buffer);
  475. }
  476. /******************************************************** sel_country() ****/
  477.  
  478. /************************************/
  479. /* Procedure de selection d'un pays */
  480. /************************************/
  481.  
  482. int    sel_country(
  483.     int    max_sel,
  484.     void    print_func()
  485.     )
  486. {
  487.  
  488.     UWORD code;
  489.     ULONG class;
  490.     APTR object;
  491.     struct IntuiMessage *message;
  492.     struct    Window *sel_wG;
  493.     struct    RastPort  *sel_rpG;
  494.     int    quit_flag;
  495.     int    x,y;
  496.     int    oldpx,oldpy;
  497.     int    result;
  498.  
  499.     /***********************************************************/
  500.     /* Ouvre la fenetre de selection et attend que l'on clique */
  501.     /***********************************************************/
  502.  
  503.     result=-1;
  504.     printf("Select country!\n");
  505. /*    selNewWindowStructure1.Screen = sC;
  506.     sel_wG = OpenWindow(&selNewWindowStructure1);*/
  507.     if(sel_wG==NULL){
  508.         printf("Error opening selection window\n");
  509.     }else{
  510.         sel_rpG = sel_wG->RPort;
  511.         SetDrMd(sel_rpG,COMPLEMENT);
  512.  
  513.         print_func(sel_rpG);
  514.         oldpx=8;
  515.         oldpy=13;
  516.         draw_rect(sel_rpG,oldpx,oldpy,100,10);
  517.         quit_flag=FALSE;
  518.         do{
  519.             WaitPort(sel_wG->UserPort);
  520.  
  521.             while( (message = (struct IntuiMessage *)
  522.                 GetMsg(sel_wG->UserPort) ) != NULL)
  523.             {
  524.                 code = message->Code;  /* MENUNUM */
  525.                 object = message->IAddress;  /* Gadget */
  526.                 class = message->Class;
  527.                 x=message->MouseX;
  528.                 y=message->MouseY;
  529.                 ReplyMsg((struct Message *)message);
  530.                 if ( class == CLOSEWINDOW ) (quit_flag = TRUE);
  531.                 if( class == MOUSEBUTTONS){
  532.                     if( code == SELECTDOWN){
  533.                         result=(((y-13)/10)%8+8*((x-8)/100))%max_sel;
  534.                         quit_flag=TRUE;
  535.                         printf("result=%d\n",result);
  536.                     }
  537.                 }
  538.                 if ( class == MOUSEMOVE ){
  539.                     x=((x-8)/100)*100+8;
  540.                     y=((y-13)/10)*10+13;
  541.                     if( ((oldpx!=x)||(oldpy!=y))&&(y>=13) ){
  542.                         SetAPen(sel_rpG,1L);
  543.                         draw_rect(sel_rpG,oldpx,oldpy,100,10);
  544.                         oldpx=x;
  545.                         oldpy=y;
  546.                         draw_rect(sel_rpG,oldpx,oldpy,100,10);
  547.                     }
  548.                 }
  549.             }
  550.         } while (quit_flag == FALSE);
  551.  
  552.         CloseWindow(sel_wG);
  553.     }
  554.     return(result);
  555. }
  556.  
  557. /****************************************************************************/
  558.  
  559. int find_country(
  560.     int    x,
  561.     int    y)
  562. {
  563.     int i,num_country;
  564.     COUNTRY *p_c;
  565.  
  566.     num_country=-1;
  567.     x=((x)*(maxx-minx))/(wG->GZZWidth)+minx;
  568.     y=((y)*(maxy-miny))/(wG->GZZHeight)+miny;
  569.     for(i=0;(i<max_country)&&(num_country==-1);i++){
  570.         p_c=&tab_country[i];
  571.         if( (x<p_c->c_clip.maxx) && (x>p_c->c_clip.minx) &&
  572.             (y<p_c->c_clip.maxy) && (y>p_c->c_clip.miny)){
  573.             num_country=i;
  574.         }
  575.     }
  576.  
  577.     return(num_country);
  578. }
  579.  
  580. static VOID fail(APTR app,char *str)
  581. {
  582.     if (app)
  583.         MUI_DisposeObject(app);
  584.  
  585.     if (MUIMasterBase)
  586.         CloseLibrary(MUIMasterBase);
  587.  
  588.     if (str)
  589.     {
  590.         puts(str);
  591.         exit(20);
  592.     }
  593.     exit(0);
  594. }
  595.  
  596. static VOID init(VOID)
  597. {
  598. #ifndef _DCC
  599.     if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  600.         fail(NULL,"Failed to open "MUIMASTER_NAME".");
  601. #endif
  602. }
  603. /*********************************************************** main() ****/
  604.  
  605. main(
  606.     int    argc,
  607.     char    **argv
  608.     )
  609. {
  610.     char    *buffer;
  611.  
  612.  
  613.     tab_vect=(BORDER *)malloc(sizeof(BORDER)*MAX_BORDER);
  614.     tab_country=(COUNTRY *)malloc(sizeof(COUNTRY)*MAX_COUNTRY);
  615.  
  616.     IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
  617.     if (IntuitionBase == NULL)
  618.     {
  619.         printf("intuition is not here.  where are we?\n");
  620.         goto cleanup1;
  621.     }
  622.     GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
  623.     ReqBase = (struct ReqBase *)OpenLibrary("req.library", 0L);
  624.  
  625.     if(ReqBase==NULL){
  626.         printf("I Can't open req.library!\n");
  627.         goto cleanup1;
  628.     }
  629.     init();            /* Mui function */
  630.  
  631.     NewScreenStructure.Height=256;
  632.     sC = OpenScreen(&NewScreenStructure);    /* open screen if present */
  633.     NewWindowStructure1.Screen = sC;
  634.     if(sC==NULL)goto cleanup1;
  635.     vP = sC->ViewPort;
  636.     wG->Height=sC->Height;
  637.     wG=OpenWindow(&NewWindowStructure1);
  638.  
  639.     AP_Main = ApplicationObject,
  640.         MUIA_Application_Title         , "AmiGlobe",
  641.         MUIA_Application_Version       , "$VER:AmiGlobe 1.0 (28.10.93)",
  642.         MUIA_Application_Copyright     , "Copyright ©1993, T.Landspurg",
  643.         MUIA_Application_Author        , "Thomas Landspurg",
  644.         MUIA_Application_Description   , "AmiGlobe",
  645.         MUIA_Application_Base          , "AmiGlobe Base",
  646.         MUIA_Application_Menu          , Menu,
  647.  
  648.         SubWindow,
  649.             WI_Cmd = WindowObject,
  650.             MUIA_Window_Title, "Commandes",
  651.             MUIA_Window_ID   , MAKE_ID('C','M','D','1'),
  652.             MUIA_Window_Screen,    sC,
  653.             WindowContents, VGroup,
  654.  
  655.                 Child, HGroup,  MUIA_Group_SameWidth, TRUE,
  656.                     Child, BT_Cmd_Panel = KeyButton("Cmd Panel",'c'),
  657.                     Child, BT_Redraw = KeyButton("Redraw",'r'),
  658.                     Child, BT_Info = KeyButton("Info",'i'),
  659.                     Child, BT_Fill     = KeyButton("Fill"  ,'f'),
  660.                     End,
  661.                 End,
  662.             End,
  663.  
  664.  
  665.         SubWindow,
  666.             WI_Cmd_Edit = WindowObject,
  667.             MUIA_Window_Title, "Commandes2",
  668.             MUIA_Window_ID   , MAKE_ID('C','M','D','2'),
  669.             MUIA_Window_Screen,    sC,
  670.             WindowContents, HGroup,
  671.  
  672.                 Child, VGroup,  MUIA_Group_SameWidth, TRUE,
  673.                     Child, BT_Move       = KeyButton("Move Pt",'m'),
  674.                     Child, BT_Zoom       = KeyButton("Zomm",'+'),
  675.                     Child, BT_Zoom_Out   = KeyButton("Zoom out",'-'),
  676.                     Child, BT_Show_Pt    = KeyButton("Show Pt"  ,'s'),
  677.                     Child, BT_Edit       = KeyButton("Edit"  ,'e'),
  678.                     End,
  679.  
  680.                 End,
  681.             End,
  682.  
  683.  
  684.         End;
  685.     if (!AP_Main) fail(AP_Main,"Failed to create application.");
  686.  
  687.     /* On indique qu'une fermeture de la fenetre Cmd principale= fermeture    */
  688.     /* de l'appli                                */
  689.     DoMethod(    WI_Cmd        ,MUIM_Notify,
  690.             MUIA_Window_CloseRequest,TRUE,
  691.             AP_Main        ,2,
  692.             MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  693.  
  694.     /* Fermeture de cmd panel                */
  695.     DoMethod(    WI_Cmd_Edit    ,MUIM_Notify,
  696.             MUIA_Window_CloseRequest,TRUE,
  697.             WI_Cmd_Edit    ,3,
  698.             MUIM_Set,MUIA_Window_Open,FALSE);
  699.  
  700.     DoMethod(    WI_Cmd_Edit    ,MUIM_Notify,
  701.             MUIA_Window_CloseRequest,TRUE,
  702.             AP_Main     ,2,
  703.             MUIM_Application_ReturnID,ID_MODE_NOT_EDIT
  704.             );
  705.  
  706.     DoMethod(    BT_Cmd_Panel    ,MUIM_Notify,
  707.             MUIA_Pressed    ,FALSE,
  708.             WI_Cmd_Edit     ,3,
  709.             MUIM_Set    ,MUIA_Window_Open,TRUE);
  710.  
  711.     DoMethod(    BT_Cmd_Panel    ,MUIM_Notify,
  712.             MUIA_Pressed    ,FALSE,
  713.             AP_Main     ,2,
  714.             MUIM_Application_ReturnID,ID_MODE_EDIT
  715.             );
  716.  
  717.     DoMethod(    BT_Info       ,MUIM_Notify,
  718.             MUIA_Pressed    ,FALSE,
  719.             AP_Main        ,2,
  720.             MUIM_Application_ReturnID,ID_INFO);
  721.  
  722.     DoMethod(    BT_Redraw    ,MUIM_Notify,
  723.             MUIA_Pressed    ,FALSE,
  724.             AP_Main        ,2,
  725.             MUIM_Application_ReturnID,ID_REDRAW);
  726.  
  727.     DoMethod(    BT_Fill       ,MUIM_Notify,
  728.             MUIA_Pressed    ,FALSE,
  729.             AP_Main        ,2,
  730.             MUIM_Application_ReturnID,ID_FILL);
  731.  
  732.     DoMethod(    BT_Move       ,MUIM_Notify,
  733.             MUIA_Pressed    ,FALSE,
  734.             AP_Main        ,2,
  735.             MUIM_Application_ReturnID,ID_MOVE_PT);
  736.  
  737.     DoMethod(    BT_Zoom       ,MUIM_Notify,
  738.             MUIA_Pressed    ,FALSE,
  739.             AP_Main        ,2,
  740.             MUIM_Application_ReturnID,ID_ZOOM);
  741.  
  742.     DoMethod(    BT_Zoom_Out    ,MUIM_Notify,
  743.             MUIA_Pressed    ,FALSE,
  744.             AP_Main        ,2,
  745.             MUIM_Application_ReturnID,ID_ZOOM_OUT);
  746.  
  747.     DoMethod(    BT_Show_Pt    ,MUIM_Notify,
  748.             MUIA_Pressed    ,FALSE,
  749.             AP_Main        ,2,
  750.             MUIM_Application_ReturnID,ID_SHOW_PT);
  751.  
  752.     DoMethod(    BT_Edit       ,MUIM_Notify,
  753.             MUIA_Pressed    ,FALSE,
  754.             AP_Main        ,2,
  755.             MUIM_Application_ReturnID,ID_EDIT);
  756.  
  757.     set(WI_Cmd,MUIA_Window_Open,TRUE);
  758.  
  759. /*
  760.     LoadRGB4(&vP,&Palette,PaletteColorCount);
  761. */
  762.     rpG = wG->RPort;
  763.     /* Window 2 */
  764.  
  765.     buffer=(char *)AllocRaster(MAXX,MAXY);
  766.     if(buffer==NULL){
  767.         printf("Error allocating buffer!\n");
  768.         goto cleanup1;
  769.     }
  770.  
  771.     InitArea(&myareainfo,areabuffer,MAX_AREA_PT);
  772.     rpG->AreaInfo=&myareainfo;
  773.     rpG->TmpRas=(struct TmpRas *)InitTmpRas(&tmpras,buffer,RASSIZE(MAXX,MAXY));
  774.  
  775. /*
  776.     SetMenuStrip(wG,&MenuList1);
  777. */
  778.     if(argc<2){
  779.         read_map("tst_map");
  780.     }else{
  781.         read_map(argv[1]);
  782.     }
  783.     printf("draw map ok!\n");
  784.  
  785.     signal_wG=(1<<wG->UserPort->mp_SigBit);
  786. /*    signal_cmd_wG=(1<<cmd_wG->UserPort->mp_SigBit);
  787.     signal_all=signal_wG | signal_cmd_wG;
  788. */
  789.     main_loop();
  790.     
  791. cleanup3:
  792. /*
  793.     ClearMenuStrip(wG);
  794. */
  795. cleanup2:
  796. /*
  797.     if(cmd_wG!=0)CloseWindow(cmd_wG);
  798. */
  799. cleanup1:
  800.     if(wG!=0)CloseWindow(wG);
  801.     if(AP_Main)MUI_DisposeObject(AP_Main);
  802.     if(sC!=0)CloseScreen(sC);
  803.     if(buffer!=NULL)FreeRaster(buffer,MAXX,MAXY);
  804.     if (GfxBase != NULL) CloseLibrary((struct Library *)GfxBase);
  805.     if (IntuitionBase != NULL) CloseLibrary((struct Library *)IntuitionBase);
  806.     if (ReqBase != NULL) CloseLibrary((struct Library *)ReqBase);
  807.     if (MUIMasterBase)
  808.         CloseLibrary(MUIMasterBase);
  809.  
  810.     return(0);
  811.  
  812. }
  813.  
  814. /****************************************************************************/
  815.  
  816. void main_loop(void)
  817. {
  818.     UWORD code;
  819.     ULONG class;
  820.     APTR object;
  821.     int    x,y;
  822.     ULONG signal_rec;
  823.     int    new_pays,old_pays;
  824.     char    buffer[100];
  825.  
  826.     struct IntuiMessage *message;    /* the message the IDCMP sends us */
  827.     struct    IntuiMessage copy_msg;
  828.  
  829.     old_pays=-1;
  830.     {
  831.         ULONG signal=0;
  832.         BOOL running = TRUE;
  833.         char *buf;
  834.  
  835.         while (running)
  836.         {
  837.             do{
  838.             switch (DoMethod(AP_Main,MUIM_Application_Input,&signal))
  839.             {
  840.                 case MUIV_Application_ReturnID_Quit:
  841.                     running = FALSE;
  842.                     break;
  843.  
  844.                 case ID_ABOUT:
  845.                     MUI_Request(AP_Main, WI_Cmd, 0, NULL, "OK", "AmiGlobe");
  846.                     break;
  847.                 case ID_REDRAW:
  848.                     cmd_redraw();
  849.                     break;
  850.                 case ID_INFO:
  851.                     cmd_info();
  852.                     break;
  853.                 case ID_FILL:
  854.                     cmd_fill();
  855.                     break;
  856.                 case ID_MOVE_PT:
  857.                     cmd_move_pt();
  858.                     break;
  859.                 case ID_SHOW_PT:
  860.                     cmd_show_pt();
  861.                     break;
  862.                 case ID_ZOOM:
  863.                     cmd_zoom();
  864.                     break;
  865.                 case ID_ZOOM_OUT:
  866.                     cmd_zoom_out();
  867.                     break;
  868.                 case ID_EDIT:
  869.                     cmd_edit();
  870.                     break;
  871.                 case ID_MODE_EDIT:
  872.                     flg_edit=TRUE;
  873.                     printf("Flg edit\n");
  874.                     break;
  875.                 case ID_MODE_NOT_EDIT:
  876.                     printf("Flg not edit\n");
  877.                     flg_edit=FALSE;
  878.                     break;
  879.             }
  880.                   }while(signal==0);
  881.             if(running){
  882.                 printf("signal:%lx signal wg:%lx\n",signal,signal_wG);
  883.                 signal_rec=Wait( signal | signal_wG );
  884.                 printf("Signal recu:%lx\n",signal_rec);
  885.             }
  886.  
  887.             if(signal_rec & signal_wG){
  888.                 while( (message = (struct IntuiMessage *)
  889.                     GetMsg(wG->UserPort) ) != NULL)
  890.                {
  891.                 copy_msg=*message;
  892.                 code = message->Code;  /* MENUNUM */
  893.                 object = message->IAddress;  /* Gadget */
  894.                 class = message->Class;
  895.                 x= message->MouseX;
  896.                 y= message->MouseY;
  897.                 ReplyMsg((struct Message *)message);
  898.                 if(flg_edit==FALSE){
  899.                 switch(class){
  900.                    case CLOSEWINDOW:
  901.                     running=FALSE;
  902.                     break;
  903.                    case MOUSEBUTTONS:
  904.                     if(code == SELECTDOWN) {
  905.                     country_sel=find_country(x,y);
  906.                     aff_selection();
  907.                     fill_country(country_sel,10);
  908.                     }
  909.                     case MOUSEMOVE :
  910.                        if(flg_edit==FALSE){
  911.                     new_pays=find_country(x,y);
  912.                     if(new_pays!=old_pays){
  913.                        if(new_pays!=-1){
  914.                         sprintf(buffer,"%10s",tab_country[new_pays].name);
  915.                        }else{
  916.                         sprintf(buffer,"          ");
  917.                        }
  918.                        old_pays=new_pays;
  919.                        IPrint(rpG,100,20,buffer);
  920.                     }
  921.                       }
  922.                     }
  923.                 }else{
  924.                     edit_loop(©_msg);
  925.                 }    
  926.                     
  927.                }
  928.             }
  929.  
  930.         }/* Fin de WHILE running */
  931.     }
  932.     return;
  933.  
  934. }
  935.  
  936. /****************************************************************************/
  937.  
  938. tst_end(
  939.     FILE    *input
  940.     )
  941. {
  942.     char c;
  943.     int    code_ret;
  944.  
  945.     /* lecture du prochain caractere */
  946.     do{
  947.         c=getc(input);
  948.         if(c=='#'){
  949.             do{
  950.                 c=getc(input);
  951.             }while((c!=0x0a)&&(c!=-1));
  952.             c=getc(input);
  953.         }
  954.  
  955.     }while((!isalnum(c))&&(c!='-'));
  956.     if((!isalpha(c))||(c=='-')){
  957.         ungetc(c,input);
  958.         code_ret=FALSE;
  959.     }else{
  960.         code_ret=TRUE;
  961.     }
  962.     return(code_ret);
  963. }
  964.  
  965. /****************************************************************************/
  966.  
  967. void tstpt(
  968.     int    x,
  969.     int    y,
  970.     int    *pmx,
  971.     int    *pmy,
  972.     int    *pMX,
  973.     int    *pMY
  974.     )
  975. {
  976.     if(x<*pmx){
  977.         *pmx=x;
  978.     }
  979.     if(x>*pMX){
  980.         *pMX=x;
  981.     }
  982.     if(y<*pmy){
  983.         *pmy=y;
  984.     }
  985.     if(y>*pMY){
  986.         *pMY=y;
  987.     }
  988. }
  989. /****************************************************************************/
  990.  
  991. int    tstclip(
  992.     int    mx,
  993.     int    my,
  994.     int    MX,
  995.     int    MY,
  996.     CLIP *p_clip
  997.     )
  998. {
  999.     int    code_ret;
  1000.  
  1001.     if((mx>p_clip->maxx)||(MX<p_clip->minx)||
  1002.        (my>p_clip->maxy)||(MY<p_clip->miny)){
  1003.         code_ret=FALSE;
  1004.     }else{
  1005.         code_ret=TRUE;
  1006.     }
  1007.     return(code_ret);
  1008. }
  1009.  
  1010. /*********************************************************** read_map() ***/
  1011.  
  1012. void read_map(
  1013.     char *p_filename
  1014.     )
  1015. {
  1016.     FILE *input;
  1017.     int    x, y;
  1018.     int mx,my,MX,MY;
  1019.     struct RastPort *r;
  1020.     struct Window *w;
  1021.     
  1022.     char str[100];
  1023.     int    flg_zone,flg_country,flg_border;
  1024.     int    flg_end;
  1025.     int    num_country;
  1026.     int    num_bord;
  1027.     int    tab_bord_tempo[MAX_VECT];
  1028.     int    i,*p_alloc;
  1029.     /* Vecteur courant */
  1030.     struct vect *v;
  1031.     VECT    *V;
  1032.     int    num_vect,nb_vect;
  1033.  
  1034.     printf("Lecture de %s\n",p_filename);
  1035.     flg_end=FALSE;
  1036.     r = rpG;
  1037.     w = wG;
  1038.     SetRast(r,0L);
  1039.     SetAPen(r,1L);
  1040.     SetBPen(r,0L);
  1041.     if (input = fopen(p_filename,"r"))
  1042.     {
  1043.  
  1044.         /* Premiere chose, la taille max de notre carte...*/
  1045.  
  1046.         fscanf(input,"%ld%ld%ld%ld",&minx,&miny,&maxx,&maxy);
  1047.         printf("minx:%ld miny:%ld maxx:%ld maxy:%ld\n",minx,miny,maxx,maxy);
  1048.  
  1049.         /********************************************************/
  1050.         /* Puis la liste des bords de pays. C'est une liste    */
  1051.         /* de points terminee par le couple -1 -1        */
  1052.         /********************************************************/
  1053.  
  1054.         printf("Lecture des borders\n");
  1055.         num_bord=0;
  1056.         flg_zone=TRUE;
  1057.  
  1058.         do{
  1059. #ifdef    TOMDEBUG
  1060.             printf("Vecteur numero:%d\n",num_bord);
  1061. #endif
  1062.             tab_vect[num_bord].p_vect=(VECT *)malloc(MAX_VECT*sizeof(struct vect));
  1063.             v=(struct vect *)tab_vect[num_bord].p_vect;
  1064.  
  1065.  
  1066.             /* Lecture de composantes d'un bord */
  1067.             mx=100000;
  1068.             my=100000;
  1069.             MX=-100000;
  1070.             MY=-100000;
  1071.  
  1072.             flg_border=TRUE;
  1073.             nb_vect=0;
  1074.             do{
  1075.                 fscanf(input,"%ld%ld",&x,&y);
  1076.                 v->x=x;
  1077.                 v->y=-y;
  1078.                 tstpt(v->x,v->y,&mx,&my,&MX,&MY);
  1079. #ifdef    TOMDEBUG
  1080.                 printf("x:%d y:%d  -> :%ld %ld\n",x,y,v->x,v->y);
  1081. #endif
  1082.                 v++;
  1083.                 nb_vect++;
  1084.  
  1085.                 if((x==-1)&&(y==-1)){
  1086.                     v->x=-1;
  1087.                     v->y=-1;
  1088. #ifdef    TOMDEBUG
  1089.                     printf("End of bord\n");
  1090. #endif
  1091.                     flg_border=FALSE;
  1092.                 }
  1093.                 if(nb_vect>=MAX_PT){
  1094.                     printf("Error :max number of pt exceeded...\n");
  1095.                     flg_border=FALSE;
  1096.                 }
  1097.             }while(flg_border==TRUE);
  1098.             tab_vect[num_bord].b_clip.minx=mx;
  1099.             tab_vect[num_bord].b_clip.miny=my;
  1100.             tab_vect[num_bord].b_clip.maxx=MX;
  1101.             tab_vect[num_bord].b_clip.maxy=MY;
  1102. /*
  1103.             printf(" Il y a eu:%d pt dans ce bord\n",nb_vect);
  1104. */
  1105.             tab_vect[num_bord].nb_vect=nb_vect-1;
  1106.  
  1107.             num_bord++;
  1108.  
  1109.             if(tst_end(input)==TRUE){
  1110. /*
  1111.                 printf("End of border def\n");
  1112. */
  1113.                 flg_zone=FALSE;
  1114.             }
  1115.  
  1116.         }while(flg_zone==TRUE);
  1117.         max_border=num_bord;
  1118.  
  1119.         num_country=0;
  1120.  
  1121.         do{
  1122.             /***************************************************/
  1123.             /* D'abord le nom de la zone                       */
  1124.             /* On alloue de la memoire pour sauvegarder ce nom */
  1125.             /* et on le recopie                   */
  1126.             /***************************************************/
  1127.  
  1128.             fscanf(input,"%d",&tab_country[num_country].continent);
  1129.  
  1130.             fscanf(input,"%s",str);
  1131. #ifdef    TOMDEBUG
  1132.             printf("Country name:%s\n",str);
  1133. #endif
  1134.             tab_country[num_country].name=(char *)malloc(strlen(str)+1);
  1135.             strcpy(tab_country[num_country].name,str);
  1136.  
  1137.             /* Debut du dessin */
  1138.  
  1139.             flg_country=TRUE;
  1140.  
  1141.             /************************************************/
  1142.             /* On recupere les numeros de border de ce pays */
  1143.             /* puis pour chaque bord on affiche ses vecteurs*/
  1144.             /************************************************/
  1145.             mx=100000;
  1146.             my=100000;
  1147.             MX=-100000;
  1148.             MY=-100000;
  1149.             num_bord=0;
  1150.             do{
  1151.                 fscanf(input,"%d",&num_vect);
  1152. /*
  1153.                 printf("Vecteur num:%d\n",num_vect);
  1154. */
  1155.     
  1156.                 tab_bord_tempo[num_bord]=num_vect;
  1157.  
  1158.     
  1159.                 V=tab_vect[num_vect].p_vect;
  1160.                 MyMove(r,V[0].x,V[0].y);
  1161.                 tstpt(V[0].x,V[0].y,&mx,&my,&MX,&MY);
  1162.                 for(i=1;i<tab_vect[num_vect].nb_vect;i++){
  1163.                     MyDraw(r,V[i].x,V[i].y);
  1164.                     tstpt(V[i].x,V[i].y,&mx,&my,&MX,&MY);
  1165.                 }
  1166.                 num_bord++;
  1167.                 if(num_bord>=MAX_VECT){
  1168.                     printf("ERROR:Max number of border excedded\n");
  1169.                     flg_end=TRUE;
  1170.                 }
  1171.  
  1172.             }while(tst_end(input)==FALSE);
  1173.             tab_country[num_country].c_clip.minx=mx;
  1174.             tab_country[num_country].c_clip.miny=my;
  1175.             tab_country[num_country].c_clip.maxx=MX;
  1176.             tab_country[num_country].c_clip.maxy=MY;
  1177.             MyMove(r,mx,my);
  1178.             MyDraw(r,MX,my);
  1179.             MyDraw(r,MX,MY);
  1180.             MyDraw(r,mx,MY);
  1181.             MyDraw(r,mx,my);
  1182.  
  1183.             /****************************************/
  1184.             /* On sait le nombre de bord de ce pays    */
  1185.             /* on leur alloue de la memoire et on le*/
  1186.             /* recopie                */
  1187.             /****************************************/
  1188.  
  1189. /*
  1190.             printf("Il y a eu:%d bord\n",num_bord);
  1191. */
  1192.             tab_country[num_country].nb_borders=num_bord;
  1193.             p_alloc=(int *)malloc((10+num_bord)*sizeof(int));
  1194.             tab_country[num_country].p_borders=p_alloc;
  1195.             for(i=0;i<num_bord;i++){
  1196.                 *p_alloc=tab_bord_tempo[i];
  1197. /*
  1198.                 printf("%d %d\n",i,tab_bord_tempo[i]);
  1199. */
  1200.                 p_alloc++;
  1201.             }
  1202.             fscanf(input,"%d",&(tab_country[num_country].habitants));
  1203.  
  1204.             fscanf(input,"%d",&(tab_country[num_country].pnb1));
  1205.             fscanf(input,"%d",&(tab_country[num_country].pnb2));
  1206.             fscanf(input,"%d",&(tab_country[num_country].pnb3));
  1207.  
  1208.             num_country++;
  1209.             if(num_country>=MAX_COUNTRY){
  1210.                 printf("ERROR:Max number of country excedded\n");
  1211.                 flg_end=TRUE;
  1212.             }
  1213.         }while((tst_end(input)==FALSE)&&(flg_end==FALSE));
  1214.         printf("Il y a eu:%d pays et %d bords\n",num_country,max_border);
  1215.         fclose(input);
  1216.     }
  1217.     max_country=num_country;
  1218.  
  1219. }
  1220. /***************************************************** reset_bord() *****/
  1221.  
  1222. /************************************************/
  1223. /* Reinitialise les drapequ indiquant qu'un    */
  1224. /* bord a ete trace                */
  1225. /************************************************/
  1226.  
  1227. void reset_bord(void)
  1228. {
  1229.     int    i;
  1230.     for(i=0;i<max_border;i++){
  1231.         tab_vect[i].flg_draw=FALSE;
  1232.     }
  1233. }
  1234.  
  1235. /***************************************************** redraw_map() *****/
  1236.  
  1237. void redraw_map(
  1238.     int    num_continent
  1239.     )
  1240. {
  1241.     struct RastPort *r;
  1242.     struct Window *w;
  1243.     int    num_country;
  1244.     int    i,j;
  1245.     /* Vecteur courant */
  1246.     int    num_vect;
  1247.     COUNTRY    *p_count;
  1248.     VECT    *V;
  1249.  
  1250.     r = rpG;
  1251.     w = wG;
  1252.     SetRast(r,0L);
  1253.     SetAPen(r,1L);
  1254.     SetBPen(r,0L);
  1255.     SetDrMd(r,JAM1);
  1256.  
  1257.     reset_bord();
  1258.     /********************************************/
  1259.     /* Pour tout les pays de la base de donnees */
  1260.     /********************************************/
  1261.  
  1262.     for(num_country=0;num_country<max_country;num_country++){
  1263.  
  1264.       if((tab_country[num_country].continent==num_continent)||
  1265.           (num_continent==-1)){
  1266.  
  1267.         /****************************************************/
  1268.         /* Pour un pays, on connait le nom, et le nombre de */
  1269.         /* bords                        */
  1270.         /****************************************************/
  1271.  
  1272.         p_count=&tab_country[num_country];
  1273.         if(tstclip(minx,miny,maxx,maxy,&(p_count->c_clip))){
  1274.  
  1275.         for(i=0;i<p_count->nb_borders;i++){
  1276.         
  1277.             /*********************************************/
  1278.             /* Pour chaque bord, on affiche les vecteurs */
  1279.             /* correspondants a ce bord             */
  1280.             /*********************************************/
  1281.             num_vect=(p_count->p_borders)[i];
  1282.             if(tstclip(minx,miny,maxx,maxy,&(tab_vect[num_vect].b_clip))){
  1283.                if(tab_vect[num_vect].flg_draw==FALSE){
  1284.                 tab_vect[num_vect].flg_draw=TRUE;
  1285.                 V=tab_vect[num_vect].p_vect;
  1286.                 MyMove(r,V[0].x,V[0].y);
  1287.                 for(j=1;j<tab_vect[num_vect].nb_vect;j++){
  1288.                     MyDraw(r,V[j].x,V[j].y);
  1289.                 }
  1290.                 }
  1291.             }
  1292.  
  1293.         }/* fin du for sur les borders    */
  1294.          }
  1295.        }
  1296.     }/* Fin du for sur les country         */
  1297.  
  1298. }
  1299.  
  1300. /***************************************************** fill_country() *****/
  1301.  
  1302. void fill_country(
  1303.     int    num_country,
  1304.     int    color
  1305.     )
  1306. {
  1307.     struct RastPort *r;
  1308.     struct Window *w;
  1309.     long    lastx,lasty;    
  1310.     int    i,j;
  1311.     /* Vecteur courant */
  1312.     VECT    *V;
  1313.     int    num_vect;
  1314.     COUNTRY    *p_count;
  1315.  
  1316.     r = rpG;
  1317.     w = wG;
  1318.     SetAPen(r,(long)color);
  1319.     SetBPen(r,3L);
  1320.     SetOPen(r,1L);
  1321.     SetDrMd(r,JAM1);
  1322.  
  1323.  
  1324.     /****************************************************/
  1325.     /* Pour un pays, on connait le nom, et le nombre de */
  1326.     /* bords                        */
  1327.     /****************************************************/
  1328.  
  1329.     p_count=&tab_country[num_country];
  1330.  
  1331.     for(i=0;i<p_count->nb_borders;i++){
  1332.         
  1333.         /*********************************************/
  1334.         /* Pour chaque bord, on affiche les vecteurs */
  1335.         /* correspondants a ce bord             */
  1336.         /*********************************************/
  1337.         num_vect=(p_count->p_borders)[i];
  1338.         V=tab_vect[num_vect].p_vect;
  1339.         if(i==0){
  1340.             AreaMove(r,conv_x(V[0].x),conv_y(V[0].y));
  1341.             lastx=V[0].x;
  1342.             lasty=V[0].y;
  1343.         }
  1344.         if((lastx==V[0].x)&&(lasty==V[0].y)){
  1345.             for(j=1;j<tab_vect[num_vect].nb_vect;j++){
  1346.                 AreaDraw(r,conv_x(V[j].x),conv_y(V[j].y));
  1347.             }
  1348.             lastx=V[j-1].x;
  1349.             lasty=V[j-1].y;
  1350.         }else{
  1351.             j=(tab_vect[num_vect].nb_vect)-1;
  1352.             do{
  1353.                 j--;
  1354.                 AreaDraw(r,conv_x(V[j].x),conv_y(V[j].y));
  1355.             }while(j!=0);
  1356.             lastx=V[0].x;
  1357.             lasty=V[0].y;
  1358.         }
  1359.  
  1360.     }/* fin du for sur les borders    */
  1361.     AreaEnd(r);
  1362.  
  1363. }
  1364.